<template>
    <view class="ad-content-wrap">
      <view class="ad-content" @click="onTravel(adData.url)">
        <image class="bg" :src="adData.cover"></image>
      </view>
      <image class="close-icon" @click="onClose" src="~@/static/images/close-icon.png"></image>
    </view>
</template>

<script>
export default {
  name: "ad-pop",
  props: {
    adData: [Object, String,Array]
  },
  methods: {
    onTravel() {
     if (this.adData.type == 0) {
       if (this.adData.url) {
         this.onNavigateTo('/pages/web-activity/index' + '?url=' + this.adData.url);
       }
     } else if (this.adData.type == 1){
       // 打开外部浏览器
       if (this.adData.url) {
         plus.runtime.openURL(this.adData.url, function () {
           uni.showModal({
             title:this.$t('info.reminder'),
             content: this.$t('ad.tips'),
             showCancel: false
           })
         });
       }
     } else if (this.adData.type == 2) {
       if (this.adData.relate_id) {
         this.onNavigateTo(`/pages/information/details?id=${this.adData.relate_id}&type=News`);
       }

     } else if (this.adData.type == 3) {
       if (this.adData.relate_id) {
         this.onNavigateTo('/pages/contract/details1?id=' + this.adData.relate_id);
       }
     }
     this.onClose();
    },
    onNavigateTo(url) {
      uni.navigateTo({
        url: url
      });
    },
    onClose() {
      this.$emit('close')
    },
  },
}
</script>

<style scoped lang="scss">
 
    .ad-content-wrap {
      .ad-content {
        position: relative;
        display:block;
        // width: 640rpx;
        // height: 800rpx;
		width:596rpx;
		height:568rpx;
        .bg {
          display:block;
          width: 100%;
          height: 100%;
        }
      }
      .close-icon {
        display: block;
        width: 44rpx;
        height: 44rpx;
        margin: 36rpx auto;
      }
    }
</style>
